package com.github.andy0106.kersstjtl.api;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

import java.io.IOException;

public class HttpUtils {
    public static final OkHttpClient httpcli = new OkHttpClient();
    public static byte[] get(String url) throws IOException {
        final Request request = new Request.Builder()
                .url(url)
                .get()
                .build();
        Response response = httpcli.newCall(request).execute();
        return response.body().bytes();
    }

    public static byte[] post(String url, RequestBody requestBody) throws IOException {
        final Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();
        Response response = httpcli.newCall(request).execute();
        return  response.body().bytes();
    }
}
